import React, { Component } from 'react'
import { ScrollView, Text } from '@tarojs/components';
import baseNavBar from "../../layout/baseNavBar";
import Form from '../../components/form';
import store from '../../utils/store';

import './index.scss'

@baseNavBar('发布行程')
export default class Index extends Component {
  constructor() {
    super();
    this.state = {
      form: store.getValue('publishWhich'),
      options: [
        { type: 'address', key: 'start', label: '出发地', required: true },
        { type: 'address', key: 'end', label: '目的地', required: true },
        { type: 'input', key: 'phone', label: '电话', required: true },
        { type: 'date', key: 'startDate', label: '发车日期', required: false },
        { type: 'time', key: 'startTime', label: '发车时间', required: true }
      ]
    }
  }

  componentWillMount () { }
  componentDidMount () { }
  componentWillUnmount () { }
  componentDidShow () { }
  componentDidHide () { }

  onSubmit(formData) {
    console.log(formData, 'formData')
  }

  render () {
    const { options } = this.state;
    return (
      <ScrollView>
        <Form options={options} onSubmit={this.onSubmit.bind(this)} />
      </ScrollView>
    )
  }
}
